package com.smart.campus.controller;

import com.smart.campus.dto.ProtectiveGuidanceManagement;
import com.smart.campus.pojo.PagedResponse;
import com.smart.campus.pojo.ResponseResult;
import com.smart.campus.service.ProtectiveGuidanceManagementServiceFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @BelongsProject: smart-campus
 * @BelongsPackage: com.smart.campus.controller
 * @Author: 戴冰洁
 * @CreateTime: 2024-09-22  19:30
 * @Description: TODO
 * @Version: 1.0
 */
@Api(tags = "护导管理模块")
@Slf4j
@RestController
@RequestMapping(value = "protective")
public class ProtectiveGuidanceManagementController {
    @Autowired
    private ProtectiveGuidanceManagementServiceFeign protectiveGuidanceManagementServiceFeign;

    @ApiOperation(value = "护导管理查询", httpMethod = "GET", notes = "护导管理查询")
    @RequestMapping(value = "protectiveList")
    public ResponseResult<List<ProtectiveGuidanceManagement>> protectiveList(){
        return new ResponseResult<>(200,"护导管理查询成功",protectiveGuidanceManagementServiceFeign.protectiveList());
    }
    @ApiOperation(value = "护导管理新增",httpMethod = "POST",notes = "护导管理新增")
    @RequestMapping(value = "addprotective")
    public ResponseResult addprotective(@RequestBody ProtectiveGuidanceManagement protectiveGuidanceManagement){
        try {
            protectiveGuidanceManagementServiceFeign.addprotective(protectiveGuidanceManagement);
            return new ResponseResult<>(200,"护导管理新增成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult<>(444,"护导管理新增失败");
        }
    }
    @ApiOperation(value = "护导管理信息回显",httpMethod = "POST",notes = "护导管理信息回显")
    @RequestMapping(value = "protectiveById")
    public ResponseResult<ProtectiveGuidanceManagement> protectiveById(Integer id){
        return new ResponseResult<>(200,"回显成功",protectiveGuidanceManagementServiceFeign.protectiveById(id));
    }
    @ApiOperation(value = "护导管理分页查询", httpMethod = "POST", notes = "护导管理分页查询")
    @RequestMapping(value = "protectiveListById")
    public ResponseResult<PagedResponse<ProtectiveGuidanceManagement>> protectiveListById(@RequestBody ProtectiveGuidanceManagement protectiveGuidanceManagement, @RequestParam(value = "pageNum")Integer pageNum, @RequestParam(value = "pageSize")Integer pageSize){
       return new ResponseResult<>(200,"分页查询成功",protectiveGuidanceManagementServiceFeign.protectiveListById(protectiveGuidanceManagement,pageNum,pageSize));
    }
    @ApiOperation(value = "修改信息", httpMethod = "POST", notes = "修改信息")
    @RequestMapping(value = "updateprotective")
    public ResponseResult updateprotective(@RequestBody ProtectiveGuidanceManagement protectiveGuidanceManagement){
        try {
            protectiveGuidanceManagementServiceFeign.updateprotective(protectiveGuidanceManagement);
            return new ResponseResult(200,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(444,"修改失败");
        }
    }
    @ApiOperation(value = "删除信息", httpMethod = "GET", notes = "删除信息")
    @RequestMapping(value = "deleteprotective")
    public ResponseResult deleteprotective(@RequestParam(value = "id") Integer id){
        try {
            protectiveGuidanceManagementServiceFeign.deleteprotective(id);
            return new ResponseResult(200,"删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(444,"删除失败");
        }
    }

}
